﻿package plugin.viproot.handler
{
    import com.core.*;
    import flash.utils.*;
    import plugin.newvip.model.*;
    import pluginfw.nio.*;
    import pluginfw.nio.imsg.*;

    public class VipHandler extends Object implements IGroupHandler
    {

        public function VipHandler()
        {
            return;
        }// end function

        public function dealSimpleMessage(param1:ISimpleMessage) : void
        {
            switch(param1.getCmd())
            {
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function dealBufferMessage(param1:IBufferMessage) : void
        {
            var _loc_2:Object = null;
            var _loc_3:Input = null;
            var _loc_4:ByteArray = null;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            switch(param1.getCmd())
            {
                case CMDVip.GetVip:
                {
                    _loc_2 = new Object();
                    _loc_3 = new Input(null);
                    _loc_4 = param1.getBody();
                    _loc_4.position = 0;
                    _loc_3.setBytes(_loc_4);
                    _loc_2.vipLevel = _loc_3.readVarInt(false);
                    _loc_2.vipPoint = _loc_3.readVarInt(false);
                    _loc_2.vipExpCardEndTime = _loc_3.readVarInt(false);
                    _loc_2.vipDayBuff = _loc_3.readVarInt(false);
                    _loc_5 = _loc_3.readShort();
                    _loc_2.vipLevelGift = new Array();
                    _loc_6 = 0;
                    while (_loc_6 < _loc_5)
                    {
                        
                        _loc_2.vipLevelGift[_loc_6] = _loc_3.readVarInt(false);
                        _loc_6++;
                    }
                    _loc_2.privilegeCardLevel = _loc_3.readVarInt(false);
                    _loc_2.privilegeCardEndTime = _loc_3.readVarInt(false);
                    _loc_2.leftSignCount = _loc_3.readVarInt(false);
                    _loc_2.leftReliveCount = _loc_3.readVarInt(false);
                    _loc_2.leftTransCount = _loc_3.readVarInt(false);
                    ModelProxy.change("vip", "getvip", _loc_2);
                    ModelProxy.change("bag", "vip", null);
                    ModelProxy.change("bufferView", "showBindBuffer", null);
                    ModelProxy.change("mainui", "updateHero", null);
                    ModelProxy.change("fashen", "updateRein", null);
                    if (_loc_2.vipLevel > 0 && _loc_2.vipDayBuff == 0 || _loc_2.vipLevel > 0 && _loc_2.vipLevel != _loc_2.vipLevelGift.length)
                    {
                        ModelProxy.change("mainui", "playvip", null);
                    }
                    else
                    {
                        ModelProxy.change("mainui", "stopvip", null);
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function dealProxyMessage(param1:IProxyMessage) : void
        {
            return;
        }// end function

    }
}
